<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../css/four.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../css/jqe/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="../css/jqe/themes/icon.css"/>

    <script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
	<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>

    <script type="text/javascript">
    $(function(){
    	//初始化对话框
    	 $('#dw,#dwEdit').window({
    		   onBeforeClose:function(){ 
    			   //取消时关闭等待框
    			   setTimeout(function(){ 
    				   sending.style.visibility = "hidden";
				   }, 250);
    	   }});
    	
   
          $(".btnAll").each(function(i,v){
    	   //变手型
    	     $(v).mouseover(function() {
				$(this).css("cursor", "hand");
			 }).mouseout(function() {
				$(this).css("cursor", "pointer");
			 });
    	   
    	   
    	   if($(v).html()=='【新增】'){
    		   $(v).click(function(){
    			   $('#dw').window("open");
    		   });
    	   }else if($(v).html()=='【编辑】'){
      		   $(v).click(function(){
      			   //ajax
      			  /*  $.get("ajOneHw.do?hkid="+ $(v).prop("lang")+"&x="+Math.random(),function(jsonTxt){
      				   var jsonObj = eval("("+jsonTxt+")");
      				   $("#upd_hkid").val(jsonObj.hkid);
      				   $("select[id='upd_sbid']").val(jsonObj.sbid);
      				   $("#upd_hktitle").html(jsonObj.hktitle);
      				   $("#upd_hkans").html(jsonObj.hkans); 
      				   $("#upd_hkdescb").html(jsonObj.hkdescb); 
      				   $('#dwEdit').window("open");
      			   }); */
      			   $.ajax({
      				   type: "post",
      				   url: "ajOneHw.do",
      				   data:"hkid="+$(v).prop("lang")+"&x="+Math.random(),
      				   success: function(jsonTxt){
      				   var jsonObj=eval("("+jsonTxt+")");
      				   $("#upd_hkid").val(jsonObj.hkid);
     				   $("select[id='upd_sbid']").val(jsonObj.sbid);
     				   $("#upd_hktitle").html(jsonObj.hktitle);
     				   $("#upd_hkans").html(jsonObj.hkans); 
     				   $("#upd_hkdescb").html(jsonObj.hkdescb);
      				   $('#dwEdit').window("open");
      			   }
      			
      			   });  
      			   
      		   });
    	   }else if($(v).html()=='【删除】'){
    		   $(v).click(function(){
    			  if(confirm("确认删除'"+$(v).prop("title")+"'?")){
    				  location.href="delHw.do?hkid="+$(v).prop("lang"); 
    			  }
    		   });
    	   } 
       });
       
         $(".sel_sbid").change(function(){
        	
        	location.href="listHw.do?sbid="+$(".sel_sbid").val();
         });
          
          
    });
    </script>
</head>
<body>
	<!-- 包含等待框 -->
	<jsp:include page="../waittable.jsp" flush="true" />
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr valign="top">
			<td bgcolor="#FFFFFF"><table width="96%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de">
					<tr align="left" bgcolor="#F2FDFF">
						<td colspan="7" class="optiontitle">
					 <select class="sel_sbid" name="sbid" >
					 <option  value="0">全部</option>
					 <c:forEach items="${subs}" var="sub">
		             <option  ${page.params.sbid==sub.sbid?"selected='selected'":""} value="${sub.sbid}" >${sub.sbname }</option>
		            </c:forEach>
					 </select>
						科目习题库</td>
					</tr>
					<tr align="center">
						<td align="center" bgcolor="#ebf0f7">习题ID</td>
						<td align="center" bgcolor="#ebf0f7">习题创建人</td>
						<td align="center" bgcolor="#ebf0f7">习题科目</td>
						<td align="center" bgcolor="#ebf0f7">习题类型</td>
						<!-- <td align="center" bgcolor="#ebf0f7">习题推荐答案</td> -->
						<!-- <td align="center" bgcolor="#ebf0f7">习题备注</td> -->
						<td align="center" bgcolor="#ebf0f7">操作 <span class="btnAll">【新增】</span> </td>
					</tr>
					<c:forEach items="${page.results}" var="hw">
						<tr align="center" bgcolor="#FFFFFF">
						    <td align="center" bgcolor="#ebf0f7">${hw.hkid}</td>
							<td align="center">${hw.ename}</td>
							<td align="center">${hw.sbname}</td>
							<td align="center">${hw.hktitle}</td>
							<%-- <td align="center">${hw.hkans}</td>
							<td align="center">${hw.hkdescb}</td> --%>
							<td align="center">
							【<a href="oneHomework.do?hkid=${hw.hkid}">查看</a>】
									| <span class="btnAll" lang="${hw.hkid}">【编辑】</span>
								    | <span class="btnAll" lang="${hw.hkid}" title="${hw.hkid}">【删除】</span>
				               
							</td>
						</tr>
					</c:forEach>
					<tr align="right" bgcolor="#ebf0f7">
							<td colspan="7">
							<jk:page totalPage="${page.totalPage}" pageNo="${page.pageNo}" totalRecord="${page.totalRecord}"
                                url="listHw.do?sbid=${sbid }"/>
							</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
		  <td align="center" style="color: red">${msg}</td>
		</tr>
	</table>
    
	<div id="dw" class="easyui-window" title="课程设计表" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:380px;height:370px;padding:10px;display: none;">
		<form action="addHw.do" method="post">
		习题科目:&nbsp&nbsp&nbsp    <select name="sbid">
		<c:forEach items="${subs}" var="sub">
		<option value="${sub.sbid}" >${sub.sbname }</option>
		</c:forEach>
		</select>
		<br /><br />
		    习题命名 ：<textarea name="hktitle" rows="3" cols="30"></textarea><br><br>
		     推荐答案 ：<textarea name="hkans" rows="3" cols="30"></textarea><br><br>
		      习题备注 ：<textarea name="hkdescb" rows="3" cols="30"></textarea><br><br>
		      <input type="submit" value="保存"/><br>
		</form>
	</div>
	
	 <div id="dwEdit" class="easyui-window" title="修改科目练习题" data-options="modal:true,minimizable:false,closed:true,maximizable:false,iconCls:'icon-save'" style="width:380px;height:370px;padding:10px;display: none;">
		<form action="updHw.do" method="post">
		<input name="hkid" id="upd_hkid" type="hidden"/>
		习题科目:&nbsp&nbsp&nbsp <select name="sbid" id="upd_sbid" >
		
		<c:forEach items="${subs}" var="sub">
		<option value="${sub.sbid}" >${sub.sbname }</option>
		</c:forEach>
		</select>
		<br /><br />
		    习题命名 ：<textarea name="hktitle" id="upd_hktitle" rows="3" cols="30"></textarea><br><br>
		     推荐答案 ：<textarea name="hkans" id="upd_hkans" rows="3" cols="30"></textarea><br><br>
		      习题备注 ：<textarea name="hkdescb" id="upd_hkdescb" rows="3" cols="30"></textarea><br><br>
		      <input type="submit" value="保存"/><br>
		</form>
	</div>
	
</body>
</html>